import React, {Component, Fragment} from 'react';
import {inject, observer} from 'mobx-react';
import {toJS} from "mobx";
import {
    WeaLocaleProvider,
    WeaTableEditable,
    WeaDialog,
    WeaRightMenu,
    WeaTab,
} from "ecCom";
import {Button} from "antd";
import NoRightComponent from '../NoRightComponent.js';
import AddWorkflowMouldSetting from './AddWorkflowMouldSetting';
import BookmarkMatchingComponent from './BookmarkMatchingComponent';
import * as IconConstant from '../../constant/IconConstant.js';
import * as LanguageConstant from '../../constant/LanguageConstant';

import {WeaTableNew} from "comsMobx";

const {WeaTable} = WeaTableNew;
const {getLabel} = WeaLocaleProvider;

@inject("workflowSettingStore")
@observer
class ImportMouldsTable extends Component {

    componentDidMount() {
        const {workflowSettingStore} = this.props;
        const {getImportMouldTableDatas, resetImportMouldsTable} = workflowSettingStore;
        resetImportMouldsTable();
        getImportMouldTableDatas();
    }

    render() {
        const {workflowSettingStore} = this.props;
        const {
            loading, importMouldTableStore, importMouldSelectedRowKeys, importMouldRowSelection, onSaveImportMouldDatas
            , getImportMouldTableDatas
        } = workflowSettingStore;
        const dropMenuDatas = [
            {
                key: '1',
                disabled: false,
                icon: <i className='icon-coms-Preservation'/>,
                content: getLabel(LanguageConstant.SAVE, "保存"),
                onClick: key => {
                    onSaveImportMouldDatas();
                },
            }
        ];
        return (
            <WeaRightMenu datas={dropMenuDatas}>
                <WeaTab
                    searchType={['base']}
                    onSearch={value => getImportMouldTableDatas({name: value})}
                />
                <WeaTable
                    hasOrder={true}
                    needScroll={true}
                    comsWeaTableStore={importMouldTableStore}
                    rowSelection={{
                        selectedRowKeys: toJS(importMouldSelectedRowKeys),
                        onChange: importMouldRowSelection,
                    }}
                />
            </WeaRightMenu>
        );
    }

}

export default ImportMouldsTable;